package com.xhwl.logistics.util;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhwl.common.vo.PageParamVO;

import java.util.List;

public class PageResultUtils {

    public static <T> Page<T> getMyBatisPlusPage(PageParamVO param){
        return new Page<>(param.getCurrent(), param.getSize());
    }

    public static <T> Page<T> getMyBatisPlusPage(Long currentPage, Long pageSize){
        return new Page<>(currentPage, pageSize);
    }

    public static <T> PageResult<T> getPageResult(Page page, List<T> records) {
        PageResult<T> pageResult = new PageResult<>();
        pageResult.setPageNumber(page.getCurrent());
        pageResult.setPageSize(page.getSize());
        pageResult.setTotalPage(page.getPages());
        pageResult.setTotalSize(page.getTotal());
        pageResult.setRecords(records);
        return pageResult;
    }

}
